//
//  SingleTest.m
//  OCDemo
//
//  Created by wxf on 2024/8/12.
//

#import "SingleTest.h"


//全局静态变量
static SingleTest *sing = nil;
@implementation SingleTest

+ (SingleTest *)shareSingle
{
    @synchronized (self) {
        if(sing == nil){
            sing = [[SingleTest alloc] init];
        }
    }
    return sing;
}


//注意：在实际中如果需要保证单例对象得唯一性，还需要重写下面方法：allocWithZone
+(id)allocWithZone:(struct _NSZone *)zone{
    @synchronized (self) {
        if(sing == nil){
            sing = [super allocWithZone:zone];
        }
    }
    return sing;
}

@end
